package com.qian.service.ddj.listener;

import com.yaowk.api.system.event.AddUserEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.transaction.Transactional;

@Component
public class AddDdjUserListener implements ApplicationListener<AddUserEvent> {

    @PersistenceContext
    private EntityManager em;

    @Transactional
    public void onApplicationEvent(AddUserEvent addUserEvent) {
//        User user = addUserEvent.getSource();
//        Query query = em.createNativeQuery("insert into ddj_user (id,balance) values (" + user.getId() + "," + new BigDecimal(0) + ")");
//        query.executeUpdate();
    }
}
